﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace canyinguanlixitong
{
    public partial class frmupdatexm : Form
    {
        public frmupdatexm()
        {
            InitializeComponent();
        }
        public string name;
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void frmupdatexm_Load(object sender, EventArgs e)
        {
            band();
        }
        public void band() {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            string sql = "select fyName,fymoney from dbo.fybiao  where fyName='" + name + "'";
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                this.txbname.Text = reader["fyName"].ToString();
                this.txbmoney.Text = reader["fymoney"].ToString();
            }
        }

        private void btnqueding_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            string sql = "update dbo.fybiao set fymoney='" + this.txbmoney.Text + "'where fyName='" + name + "'";
            SqlCommand cmd = new SqlCommand(sql,conn);
            int i = cmd.ExecuteNonQuery();
            if (i>0)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }
    }
}
